package com.xlf.controller.admin;


import com.xlf.service.CommentService;
import com.xlf.utils.ResponseResult;
import com.xlf.vo.QueryPageBean;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评论控制层
 */

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    CommentService commentService;

    /**
     * 条件查询评论，支持分页、时间区间、分类/标签id查询
     * @param queryPageBean 分页查询条件对象
     * @return              分页查询结果
     */
    @PostMapping("/getCommentPage")
    public ResponseResult getCommentPage(@RequestBody QueryPageBean queryPageBean){
        return ResponseResult.success("获取评论分页成功",commentService.getCommentPage(queryPageBean));
    }

    /**
     * 根据id/id列表删除评论
     * @param id    id/id列表
     * @return      执行结果
     */
    @DeleteMapping("/delete")
    public ResponseResult deleteComment(@RequestBody List<Long> id){
        commentService.removeByIds(id);
        return ResponseResult.success("删除成功");
    }
}
